package com.kyzh.core.dialog

import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import com.gushenge.core.beans.GameTaskBean
import com.kyzh.core.databinding.DialogGameplayBinding
import org.jetbrains.anko.sdk27.coroutines.onClick
import per.goweii.layer.core.widget.SwipeLayout
import per.goweii.layer.dialog.DialogLayer
import per.goweii.layer.dialog.ktx.backgroundDimDefault
import per.goweii.layer.dialog.ktx.gravity
import per.goweii.layer.dialog.ktx.swipeDismiss
private var dialog : DialogLayer?=null
fun Context.showGamePlayDialog(data: GameTaskBean ){
    dialog =   DialogLayer(this)
    dialog!!.setContentView(getView(data))
        .backgroundDimDefault()
        .gravity(Gravity.CENTER)
        .swipeDismiss(SwipeLayout.Direction.BOTTOM)
        .show()
}
private fun Context.getView(data: GameTaskBean) = DialogGameplayBinding.inflate(LayoutInflater.from(this)).apply{
    d = data
    close.onClick {
        dialog?.dismiss()
    }
}.root